package com.jsyl.dao.base;

import java.util.List;
import java.util.Map;

import com.jsyl.entity.common.orm.mapper.TableMapper;

public interface SqlBuilder {

	public static final String SQL_INSERT = "INSERT INTO ";
	public static final String SQL_VALUES = " VALUES ";
	public static final String SQL_UPDATE = "UPDATE ";
	public static final String SQL_SET = " SET ";
	public static final String SQL_WHERE = " WHERE ";
	public static final String SQL_DELETE = "DELETE ";
	public static final String SQL_FROM = " FROM ";
	public static final String SQL_SELECT = "SELECT ";
	public static final String SQL_COUNT = " COUNT(1) ";
	public static final String SQL_AND = " AND ";
	public static final String SQL_OR = " OR ";
	public static final String SQL_LIKE = " LIKE ";
	public static final String SQL_IS_NULL = " IS NULL ";
	public static final String SQL_NOT_NULL = " IS NOT NULL ";
	public static final String SQL_ORDER = " ORDER BY ";
	public static final String SQL_DESC = " DESC ";
	public static final String SQL_ASC = " ASC ";
	public static final String SQL_DISTINCT = " DISTINCT ";
	public static final String SQL_IN = " IN ";
	public static final String SQL_LIMIT = " LIMIT ";
	public static final String SQL_SP = "`";

	/**
	 * 获取插入Insert SQL
	 * 
	 * @param mapper
	 * @return
	 */
	public String getInsertSql(TableMapper mapper);

	/**
	 * 获取更新Update SQL
	 * 
	 * @param mapper
	 * @return
	 */
	public String getUpdateSql(TableMapper mapper);

	/**
	 * 根据条件，获取删除 Delete SQL
	 * 
	 * @param mapper
	 * @param equalMap
	 * @param likeMap
	 * @param extraSQL
	 * @return
	 */
	public String getDeleteSql(TableMapper mapper, Map<String, Object> equalMap, Map<String, String> likeMap,
			String extraSQL);

	/**
	 * 根据条件，获取查询 Select SQL
	 * 
	 * @param venderType
	 * @param mapper
	 * @param equalMap
	 * @param likeMap
	 * @param orderMap
	 * @param extraSQL
	 * @param startIndex
	 * @param pageSize
	 * @return
	 */
	public String getSelectSql(TableMapper mapper, Map<String, Object> equalMap, Map<String, String> likeMap,
			Map<String, String> orderMap, String extraSQL, Integer startIndex, Integer pageSize);

	/**
	 * 根据条件，获取总记录数查询 Total SQL
	 * 
	 * @param mapper
	 * @param equalMap
	 * @param likeMap
	 * @param orderMap
	 * @param extraSQL
	 * @return
	 */
	public String getTotalSql(TableMapper mapper, Map<String, Object> equalMap, Map<String, String> likeMap,
			Map<String, String> orderMap, String extraSQL);

	/**
	 * 创建无查询条件的SELECT子句
	 * 
	 * @param mapper
	 * @return
	 */
	public String buildSelectSql(TableMapper mapper);

	/**
	 * 根据条件，创建WHERE子句
	 * 
	 * @param columnMapper
	 * @param equalMap
	 * @param likeMap
	 * @param orderMap
	 * @param extraSQL
	 * @return
	 */
	public String buildWhereSql(Map<String, String> columnMapper, Map<String, Object> equalMap,
			Map<String, String> likeMap, Map<String, String> orderMap, String extraSQL);

	/**
	 * 获取列名的集合
	 * 
	 * @param mapper
	 * @return
	 */
	public List<String> getColumnNames(TableMapper mapper);

}
